<div style="padding: 20px">
    <div style="display: flex">
        <div style="display: flex;align-items:center">
            <label>完整录音：</label>
            <audio controls="controls" id="whole-audio">
                <source src="{{.audio}}" type="audio/wav" />
            </audio>
        </div>
        <div style="display: flex;align-items:center">
            <label>分段录音：</label>
            <audio controls="controls" id="fenduan">
                <source src="" type="audio/wav" />
            </audio>
        </div>
    </div>
    <table class="layui-table" lay-data="{width: 'full-10', height: 'full-105', url:'/cdr/flow_content_list?call_id={{.call_id}}&other_uuid={{.other_uuid}}', page:true}" lay-filter="demo">
        <thead>
        <tr>
            <th lay-data="{field:'id', width:65, fixed: true,sort:true}">Id</th>
            <th lay-data="{field:'content', width:200,}">内容</th>
            <th lay-data="{field:'dsr_time', width:200}">时间</th>
            <th lay-data="{field:'call', width:200}">说话者</th>
            <th lay-data="{field:'fail', width:200}">禁忌</th>
            <th lay-data="{field:'fine', width:200}">常规</th>
            <th lay-data="{field:'score', width:200}">评分</th>
            <th lay-data="{fixed:'right', width:200, align:'center', toolbar: '#barTool'}"></th>
        </tr>
        </thead>
    </table>
</div>
<style>
    .nav-title{
        display: none;
    }
</style>
<script type="text/html" id="barTool">
    <a class="layui-btn layui-btn-primary layui-btn-mini" lay-event="detail">查看录音</a>
</script>
<script>
    var $;
    layui.config({
        base : "js/"
    }).use(['table','element','layer','jquery'], function(){
        var table = layui.table;
        var element = layui.element;
        $ = layui.jquery
        table.on('tool(demo)', function(obj){
            var data = obj.data;
            if(obj.event === 'detail') {
                console.log(data.record)
                var whole = document.getElementById("whole-audio");
                whole.pause();
                var audio = document.getElementById("fenduan");
                audio.pause();
                audio.currentTime = 0;
                var arr = data.record.split("/")
                audio.setAttribute("src", "/vad_dir/" + arr[arr.length-1]);
                audio.play();
            }
        });
    });

</script>
